//
//  SKUDetailScrView.m
//  ZITHER
//
//  Created by weixin on 2018/8/15.
//  Copyright © 2018年 weixn. All rights reserved.
//

#import "SKUDetailScrView.h"

@implementation SKUDetailScrView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.bounces = NO;
        self.showsHorizontalScrollIndicator = NO;
        self.bounces = NO; // 默认为YES 取消设置NO
        // 当bounces属性为NO时，以下两个属性设置无效
        self.alwaysBounceHorizontal = YES; // 水平方向弹簧效果
        self.alwaysBounceVertical = YES; // 垂直方向弹簧效果
        self.decelerationRate = 0.1; // 值域 0~1 值越小减速停止的时间越短
        self.backgroundColor = [UIColor whiteColor];
        self.pagingEnabled = YES;
        self.contentSize = CGSizeMake(kScreenW*2,0);
        self.delegate = self;
        
        
        [self setUI];
    }
    return self;
}

-(void)setUI{
    [self addSubview:self.scr1];
    [self addSubview:self.tb2];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    
    if (scrollView.contentOffset.x == 0) {
        [self changePage:0];
    }else if (scrollView.contentOffset.x == SCREEN_WIDTH){
        [self changePage:1];
    }
    
}

-(void)changePage:(int)index{
//    SKUDetailNewVc *vc  = (SKUDetailNewVc*)[self getViewController:[SKUDetailNewVc class]];
//
//    [UIView animateWithDuration:0.2 animations:^{
//        vc.viewBlcak.frame =  CGRectMake(0, 37, kScreenW/2.0, 3);
//        if (index ==0) {
//        }else{
//            vc.viewBlcak.frame =  CGRectMake(kScreenW/2.0, 37, kScreenW/2.0, 3);
//        }
//    }];
}


-(SKUDetailWatchScrView *)scr1{
    if (!_scr1) {
        _scr1 = [[SKUDetailWatchScrView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, self.frame.size.height)];
        [_scr1 setBlockUpLoadData:^{
            if (self.blockUpLoadData) {
                self.blockUpLoadData();
            }
        }];
    }
    return _scr1;
}

-(SKUDefultQuestionTB *)tb2{
    if (!_tb2) {
        _tb2 = [[SKUDefultQuestionTB alloc]initWithFrame:CGRectMake(kScreenW, 0, kScreenW, self.frame.size.height)];
    }
    return _tb2;
}


@end
